

import 'package:baby/UI/Pages/EdiucationPage/EducationPage.dart';
import 'package:baby/UI/Pages/HomePage/HomePage.dart';
import 'package:flutter/material.dart';

import 'Moments/MomentsPage.dart';
import 'ProfilePage.dart';
import 'package:baby/UI/Pages/StorePage/StorePage.dart';

class MainPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => MainPageState();
}

class MainPageState extends State<MainPage> with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
  int currentPage = 0;
  var pageViewController = PageController();

  goToPage(int index, {bool ignore = false}) {
    setState(() {
      currentPage = index;
      if (!ignore) pageViewController.animateToPage(currentPage, duration: Duration(milliseconds: 600), curve: Curves.easeOutCirc);
    });
  }

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Directionality(textDirection: TextDirection.rtl, child: Scaffold(
      body: PageView(
        children: <Widget>[
          HomePage(),
          EducationPage(),
          StorePage(),
          MomentsPage(),
          ProfilePage()
        ],
        controller: pageViewController,
        onPageChanged: (index) => goToPage(index, ignore: true),
      ),
      bottomNavigationBar: BottomNavigationBar(
        currentIndex: currentPage,
        type: BottomNavigationBarType.fixed,
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.linked_camera), title: Text("قوزام")),
          BottomNavigationBarItem(icon: Icon(Icons.nature_people), title: Text("تەربىيەم")),
          BottomNavigationBarItem(icon: Icon(Icons.store), title: Text("دۇكىنىم")),
          BottomNavigationBarItem(icon: Icon(Icons.camera), title: Text("چەمبىرەك")),
          BottomNavigationBarItem(icon: Icon(Icons.perm_identity), title: Text("مېنىڭ")),
        ],
        onTap: goToPage,
      ),)
    );
  }

  @override
  // TODO: implement wantKeepAlive
  bool get wantKeepAlive => true;
}


